/**
 * Created by Jehuty on 16/11/25.
 */
$(function () {
    swipe()
})

function swipe() {
    var height,scrollHeight;
    var screenH = window.screen.height;
    var isMove = false;

    $.ajax({
        dataType:"json",
        url:URL.getinlanddiscount,
        success:function (data) {
            var html = template("template_discount",data);
            $("#template_container").append(html);
        },
        complete:function () {
            height = $("body").height();
            //判断是否已经绑定了事件，已经绑定了就不再重复绑定
            if(!isMove){
                $(".mmb_layout")[0].addEventListener("touchend",function () {
                    isMove = true;
                    scrollHeight = $("body").scrollTop();
                    if((height - scrollHeight - screenH)<screenH/3){
                        ajax();
                    };
                })
            }
        }
    })


    function ajax() {
        $.ajax({
            dataType:"json",
            url:URL.getinlanddiscount,
            success:function (data) {
                var html = template("template_discount",data);
                $("#template_container").append(html);
            },
        })
    }

}
